<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>3.v-if的真实使用场景</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <button @click="getPerson">联系服务器获取一个人的信息</button>
      <h3>姓名：{{person.name}}</h3>
      <h3 v-if="person.age">真实年龄：{{person.age.realAge}}</h3>
      <h3 v-if="person.age">对外年龄：{{person.age.outAge}}</h3>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          person:{},
        },
        methods:{
          getPerson(){
            this.person = {name:'海峰老师',age:{realAge:40,outAge:29}}
          }
        }
      })
    </script>
  </body>
</html>